import uniqueId from '@form-create/utils/lib/unique';
import {localeProps, makeRequiredRule} from '../../utils';

const label = '文本域';
const name = 'a-textarea';

export default {
  icon: 'icon-textarea',
  label,
  name,
  rule({t}) {
    return {
      type: name,
      field: uniqueId(),
      title: t('components.textarea.name'),
      info: '',
      $required: false,
      props: {},
    };
  },
  props(_, {t}) {
    return localeProps(t, name + '.props', [
      makeRequiredRule(),
      {
        type: 'switch',
        field: 'showWordLimit',
        value: true,
        title: '是否显示输入字数统计'
      },
      {
        type: 'input',
        field: 'placeholder',
        title: '输入框占位文本',
      },
      {
        type: 'switch',
        field: 'allowClear',
        title: '是否可清空'
      },
      {
        type: 'inputNumber',
        field: 'maxlength',
        title: '最大输入长度',
        props: {
          min: 0
        }
      },
      {
        type: 'switch',
        field: 'disabled',
        title: '禁用'
      },
      {
        type: 'switch',
        field: 'readonly',
        title: '是否只读'
      }
    ]);
  },
};
